/*
    Project:        Home Power Control
    File:           HPCLogFile.cpp
    Author:         christian@karunamusic.at
    Date:           01.2015
    Description:    Log to screen (stderr).
 */

#include <iostream>
#include "HPCLogFile.h"

HPCLogFile::HPCLogFile( TLogLevel lv, const QString& fn ) : HPCLogDevice(lv)
{
    m_Out.open( fn.toStdString().c_str(), std::ios::app );
}

HPCLogFile::HPCLogFile( const QString& lv, const QString& fn ) : HPCLogDevice(lv)
{
    m_Out.open( fn.toStdString().c_str(), std::ios::app );
}

HPCLogFile::~HPCLogFile()
{
    m_Out.close();
}

void HPCLogFile::OnLog( const HPCLogMessage& lm )
{
    if ( lm.LogLevel() <= LogLevel() )
    {
        m_Out << lm << std::endl;
    }
}
